﻿using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;
using Wintellect.PowerCollections;


class PriorityQueue<T> : IEnumerable<T>
{
    OrderedBag<T> priorityQueue;

    public PriorityQueue()
    {
        priorityQueue = new OrderedBag<T>();
    }

    public int Count
    {
        get
        {
            return priorityQueue.Count;
        }
    }

    public bool Enqueue(T value)
    {
        priorityQueue.Add(value);
        return true;
    }

    public T Dequeue()
    {
        return priorityQueue.RemoveFirst();
    }


    public IEnumerator<T> GetEnumerator()
    {
         for (int i = 0; i < this.priorityQueue.Count; i++)
           yield return priorityQueue[i];
    }

    IEnumerator IEnumerable.GetEnumerator()
    {
        return ((IEnumerable<T>)this).GetEnumerator(); 
    }
}
